/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!		
  \file			filtopts.cc
  \date			Aug 2011
  \author		TNick

  \brief		Contains the implementation for FiltOpts class


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @n
 Please read ReadMe.txt and Licence.txt in root folder @n
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @n

*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include    <main.h>

#include	"filtopts.h"
#include	"ui_filtopts.h"
#include	<filters/abstractfilter.h>
#include    <data_store/pagemdl.h>
#include    <gui/mainwindow.h>


/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

/* ------------------------------------------------------------------------- */
FiltOpts::FiltOpts	(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::FiltOpts)
{
    ui->setupUi(this);


    /* loop-add filters */
    AbstractFilter * ai_iter;
    for (int i = 0; i < AbstractFilter::filt_list.count(); i++)
        {
            ai_iter = AbstractFilter::filt_list[i];
            TabPage * tab_page = new TabPage();
            tab_page->abst_flt = ai_iter;
            tab_page->user_data = ai_iter->createOptions(tab_page);

            ui->tabWidget->addTab(tab_page, ai_iter->name());
            //tab_page->show();

            tab_page->a_lw_i =
                    new QListWidgetItem(
                        ai_iter->name(),
                        ui->lw_AvailFilt);

            tab_page->a_lw_i->setCheckState(
                        (ai_iter->active() ? Qt::Checked : Qt::Unchecked));

            tab_list.append(tab_page);
        }
}
/* ========================================================================= */

/* ------------------------------------------------------------------------- */
FiltOpts::~FiltOpts	(void)
{

    delete ui;
}
/* ========================================================================= */

/* ------------------------------------------------------------------------- */
void FiltOpts::on_buttonBox_accepted()
{
    foreach (TabPage* itr_tab, tab_list) {
        itr_tab->abst_flt->saveOptions(
                    this,
                    itr_tab->a_lw_i->checkState() == Qt::Checked,
                    itr_tab->user_data);
    }

    g_MW->pageModel()->createChains();
    close();
}
/* ========================================================================= */

/*  CLASS    =============================================================== */
//
//
//
//
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
